From: Claudio Cambra Date: Mon, 10 Feb 2025 07:06:43 +0000 (+0800) Subject: gui/macOS: Add convenience inline methods to check if VFS domain identifier is illega... X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~2^2~78^2~3 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=98b392699cbec92b75f1a5a0cfce2c51d5684922;p=nextcloud-desktop.git gui/macOS: Add convenience inline methods to check if VFS domain identifier is illegal or not Signed-off-by: Claudio Cambra --- diff --git a/src/gui/macOS/fileproviderdomainmanager_mac.mm b/src/gui/macOS/fileproviderdomainmanager_mac.mm index b75c59bf7..d1660810a 100644 --- a/src/gui/macOS/fileproviderdomainmanager_mac.mm +++ b/src/gui/macOS/fileproviderdomainmanager_mac.mm @@ -43,6 +43,19 @@ static constexpr auto bundleExtensions = std::array{ QLatin1StringView(".saver"), QLatin1StringView(".mdimporter") }; +static const QRegularExpression illegalChars("[:/]"); + +inline bool hasBundleExtension(const QString &domainId) +{ + return std::any_of(bundleExtensions.begin(), bundleExtensions.end(), [&domainId](const auto &ext) { + return domainId.endsWith(ext); + }); +} + +inline bool illegalDomainIdentifier(const QString &domainId) +{ + return !domainId.isEmpty() && !illegalChars.match(domainId).hasMatch() && hasBundleExtension(domainId); +} QString domainIdentifierForAccount(const OCC::Account * const account) { @@ -50,7 +63,6 @@ QString domainIdentifierForAccount(const OCC::Account * const account) auto domainId = account->userIdAtHostWithPort(); Q_ASSERT(!domainId.isEmpty()); - static const QRegularExpression illegalChars("[:/]"); domainId.replace(illegalChars, "-"); // Some url domains like .app cause issues on macOS as these are also bundle extensions.